package com.kedacom.demo.emailgateway.service;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.kedacom.demo.emailgateway.model.Email;
import com.kedacom.demo.springrabbitex.RabbitMessageSender;

@Component("emailGatewayClientProxy")
public class EmailGatewayClientProxy {
	protected Logger logger = LoggerFactory.getLogger(getClass());
	private RabbitMessageSender rabbitMessageSender;

	/**
	 * 发送邮件
	 * 
	 * @param email
	 * @return
	 */
	public void send(Email email) {
		try {
			rabbitMessageSender.convertAndSend(email);
		} catch (Exception ex) {
			logger.debug("Exception = " + ex.getMessage());
		}
	}

	@Resource
	public void setRabbitMessageSender(RabbitMessageSender rabbitMessageSender) {
		this.rabbitMessageSender = rabbitMessageSender;
	}

	public RabbitMessageSender getRabbitMessageSender() {
		return rabbitMessageSender;
	}

}
